--[[
棋子
--]]

local Man = class("Man")

function Man:ctor(key, x, y)
	local values = {
		--车价值
		c={
			{206, 208, 207, 213, 214, 213, 207, 208, 206},
			{206, 212, 209, 216, 233, 216, 209, 212, 206},
			{206, 208, 207, 214, 216, 214, 207, 208, 206},
			{206, 213, 213, 216, 216, 216, 213, 213, 206},
			{208, 211, 211, 214, 215, 214, 211, 211, 208},

			{208, 212, 212, 214, 215, 214, 212, 212, 208},
			{204, 209, 204, 212, 214, 212, 204, 209, 204},
			{198, 208, 204, 212, 212, 212, 204, 208, 198},
			{200, 208, 206, 212, 200, 212, 206, 208, 200},
			{194, 206, 204, 212, 200, 212, 204, 206, 194}
		},

		--马价值
		m={
			{90, 90, 90, 96, 90, 96, 90, 90, 90},
			{90, 96,103, 97, 94, 97,103, 96, 90},
			{92, 98, 99,103, 99,103, 99, 98, 92},
			{93,108,100,107,100,107,100,108, 93},
			{90,100, 99,103,104,103, 99,100, 90},

			{90, 98,101,102,103,102,101, 98, 90},
			{92, 94, 98, 95, 98, 95, 98, 94, 92},
			{93, 92, 94, 95, 92, 95, 94, 92, 93},
			{85, 90, 92, 93, 78, 93, 92, 90, 85},
			{88, 85, 90, 88, 90, 88, 90, 85, 88}
		},

		--相价值
		x={
			{0, 0,20, 0, 0, 0,20, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0, 0,23, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0,20, 0, 0, 0,20, 0, 0},

			{0, 0,20, 0, 0, 0,20, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{18,0, 0, 0,23, 0, 0, 0,18},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0,20, 0, 0, 0,20, 0, 0}
		},

		--士价值
		s={
			{0, 0, 0,20, 0,20, 0, 0, 0},
			{0, 0, 0, 0,23, 0, 0, 0, 0},
			{0, 0, 0,20, 0,20, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},

			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0,20, 0,20, 0, 0, 0},
			{0, 0, 0, 0,23, 0, 0, 0, 0},
			{0, 0, 0,20, 0,20, 0, 0, 0}
		},

		--奖价值
		j={
			{0, 0, 0, 8888, 8888, 8888, 0, 0, 0},
			{0, 0, 0, 8888, 8888, 8888, 0, 0, 0},
			{0, 0, 0, 8888, 8888, 8888, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},

			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0, 0, 0, 0, 0, 0, 0},
			{0, 0, 0, 8888, 8888, 8888, 0, 0, 0},
			{0, 0, 0, 8888, 8888, 8888, 0, 0, 0},
			{0, 0, 0, 8888, 8888, 8888, 0, 0, 0}
		},

		--炮价值
		p={

			{100, 100,  96, 91,  90, 91,  96, 100, 100},
			{ 98,  98,  96, 92,  89, 92,  96,  98,  98},
			{ 97,  97,  96, 91,  92, 91,  96,  97,  97},
			{ 96,  99,  99, 98, 100, 98,  99,  99,  96},
			{ 96,  96,  96, 96, 100, 96,  96,  96,  96},

			{ 95,  96,  99, 96, 100, 96,  99,  96,  95},
			{ 96,  96,  96, 96,  96, 96,  96,  96,  96},
			{ 97,  96, 100, 99, 101, 99, 100,  96,  97},
			{ 96,  97,  98, 98,  98, 98,  98,  97,  96},
			{ 96,  96,  97, 99,  99, 99,  97,  96,  96}
		},

		--卒价值
		z={
			{ 9,  9,  9, 11, 13, 11,  9,  9,  9},
			{19, 24, 34, 42, 44, 42, 34, 24, 19},
			{19, 24, 32, 37, 37, 37, 32, 24, 19},
			{19, 23, 27, 29, 30, 29, 27, 23, 19},
			{14, 18, 20, 27, 29, 27, 20, 18, 14},

			{ 7,  0, 13,  0, 16,  0, 13,  0,  7},
			{ 7,  0,  7,  0, 15,  0,  7,  0,  7},
			{ 0,  0,  0,  0,  0,  0,  0,  0,  0},
			{ 0,  0,  0,  0,  0,  0,  0,  0,  0},
			{ 0,  0,  0,  0,  0,  0,  0,  0,  0}
		}
	}
	--黑子为红字价值位置的倒置
	values.C = table.reverse(table.clone(values.c))
	values.M = table.reverse(table.clone(values.m))
	values.X = values.x;
	values.S = values.s;
	values.J = values.j;
	values.P = table.reverse(table.clone(values.p))
	values.Z = table.reverse(table.clone(values.z))

	--棋子们
	self.args={
		--红子 中文/图片地址/阵营/权重
		c={text="车", img='r_c', my=1 ,bl="c", value=values.c},
		m={text="马", img='r_m', my=1 ,bl="m", value=values.m},
		x={text="相", img='r_x', my=1 ,bl="x", value=values.x},
		s={text="仕", img='r_s', my=1 ,bl="s", value=values.s},
		j={text="将", img='r_j', my=1 ,bl="j", value=values.j},
		p={text="炮", img='r_p', my=1 ,bl="p", value=values.p},
		z={text="兵", img='r_z', my=1 ,bl="z", value=values.z},

		--蓝子
		C={text="车", img='b_c', my=-1 ,bl="c", value=values.C},
		M={text="马", img='b_m', my=-1 ,bl="m", value=values.M},
		X={text="象", img='b_x', my=-1 ,bl="x", value=values.X},
		S={text="士", img='b_s', my=-1 ,bl="s", value=values.S},
		J={text="帅", img='b_j', my=-1 ,bl="j", value=values.J},
		P={text="炮", img='b_p', my=-1 ,bl="p", value=values.P},
		Z={text="卒", img='b_z', my=-1 ,bl="z", value=values.Z}
	};


	self.pater = key:sub(1,1);
	local o = self.args[self.pater]
	self.o = o
	self.x = x or 0;
	self.y = y or 0;
	self.key = key ;
	self.my = o.my;
	self.text = o.text;
	self.value = o.value;
	self.isShow = true;
	self.alpha = 1;
	self.ps = {}; --着点


	self:register()
end


function Man:register()
end


--可以走的点
function Man:bl(map)
	local map = map or g.rule.map
	self.ps = g.rule[self.o.bl](g.rule, self.x,self.y, map, self.my)
	return self.ps
end


return Man